You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Classes > TMtxExpression Class > TMtxExpression Methods > DefineVector Method > TMtxExpression.DefineVector Method ([In] string, [In] TVec)
Dew Math for .NET
ContentsIndexHome
Example

Use parser to evaluate the "-s*x" formula where x(1,-1,1) is vector and s=0.5 scalar. To evaluate vector, use automatically generated vector.

using Dew.Math; using Dew.Math.Units; namespace Dew.Examples() { void Example() { // 1. Define variables TVectorValue = MyParser.DefineVector("x"); TDoubleValue s = MyParser.DefineDouble('s'); // 2. Set values x.Value.SetIt(false,new double[] {1,-1,1}); s.DoubleValue = 0.5; // 3. Add formula and evaluate, MyParser.AddExpr("-s*x"); Vector res = new Vector(0); res = MyParser.EvaluateVector(); // res = (-0.5,0.5, -0.5) } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.